package com.linyu.huawei.simple;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * BasketballPro
 * 2023A-投篮比赛
 *
 * @author 23087
 * @since 2024/11/29
 */
public class BasketballPro {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] orgs = sc.nextLine().split(" ");
        ArrayList<Integer> numList = new ArrayList<>();
        for (String record : orgs) {
            if (!record.equals("+") && !record.equals("D") && !record.equals("C")){ // 如果为数字
                numList.add(Integer.parseInt(record));
            }else if (record.equals("D")){ // 如果是 D 则为前一次的两倍
                numList.add(numList.get(numList.size()-1) * 2);
            }else if (record.equals("C")){ // 如果是 C 则表示这一轮得分无效且前一次得分无效
                numList.remove(numList.size() - 1);
            }else {
                numList.add(numList.get(numList.size()-1) + numList.get(numList.size()-2));
            }
        }
        int result = 0;
        for (Integer num : numList) {
            result += num;
        }
        System.out.println(result);

    }

}